/*
package es.web;

import com.es.entity.TestLogInfo;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.MatchQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.aggregation.AggregatedPage;
import org.springframework.data.elasticsearch.core.query.IndexQuery;
import org.springframework.data.elasticsearch.core.query.IndexQueryBuilder;
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

*/
/**
 * @author: LCG
 * 作者: LCG
 * 日期: 2021/5/24  10:41
 * 描述:
 *//*

@RestController
public class TestEsControler {

    @Autowired
    private ElasticsearchTemplate elasticsearchTemplate;


    */
/**
     * 作者: LCG
     * 日期: 2021/5/24  10:47
     * 描述: 增删改查 来一套
     * @Param []
     * @Return void
     *//*

    @RequestMapping("test01")
    public void test01(){
        //判断索引是不是存在
        */
/*boolean indexExists = elasticsearchTemplate.indexExists("tttt-index");
        if(!indexExists){
            elasticsearchTemplate.createIndex("tttt-index");
        }*//*


        //插入数据
        TestLogInfo map=new TestLogInfo();
        map.setId(System.currentTimeMillis());
        map.setCreateTime(new Date());
        map.setParameter("参数信息");
        IndexQuery indexQuery=new IndexQueryBuilder().withObject(map).build();
        elasticsearchTemplate.index(indexQuery);

    }


    */
/**
     * 作者: LCG
     * 日期: 2021/5/24  11:21
     * 描述: 查询
     * @Param []
     * @Return void
     *//*

    @RequestMapping("test02")
    public void test02(){

        //构建查询条件
        MatchQueryBuilder matchQueryBuilder = QueryBuilders.matchQuery("parameter", "参");

        //构建本地查询
        NativeSearchQuery build = new NativeSearchQueryBuilder().withQuery(matchQueryBuilder).build();

        //执行查询
        List<TestLogInfo> testLogInfos = elasticsearchTemplate.queryForList(build, TestLogInfo.class);

        System.out.println(testLogInfos);

    }

    */
/**
     * 作者: LCG
     * 日期: 2021/5/24  11:34
     * 描述: 多个条件的查询
     * @Param []
     * @Return void
     *//*

    @RequestMapping("test03")
    public void  test03(){
        BoolQueryBuilder must = QueryBuilders.boolQuery().must(QueryBuilders.matchQuery("parameter", "参数"));

        String pre="<span style=\"color:red\">";
        String pos="</span>";

        NativeSearchQuery nativeSearchQuery = new NativeSearchQueryBuilder()
                .withQuery(must)
                .withIndices("tttt-index")
                .withHighlightFields(new HighlightBuilder.Field("parameter").postTags(pos).preTags(pre))
                .withPageable(PageRequest.of(1,2))
                .build();

        AggregatedPage<TestLogInfo> testLogInfos = elasticsearchTemplate.queryForPage(nativeSearchQuery, TestLogInfo.class);

        List<TestLogInfo> collect = testLogInfos.get().collect(Collectors.toList());

        Pageable pageable = testLogInfos.getPageable();
        System.out.println("pageAble: "+pageable);
        System.out.println(collect);

    }


}
*/
